package n3291;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner cin=new Scanner(System.in);
		
		while(cin.hasNext())
		{
			String a=cin.next();
			String b=cin.next();
			if(a.equals("0"))break;
			int len=lcs(a,b);
			int max=Math.max(a.length(), b.length());
			int min=Math.min(a.length(), b.length());
			if(len*2>=max)System.out.println(1);
			else if(a.length()==b.length()) {
				System.out.println(2);
			}
			else {
				int result=1;
				while(len*2<max)
				{
					len+=min;
					min+=min;
					result++;
				}
				System.out.println(result);
			}
		}
		
	}
	
	public static int lcs(String a,String b)
	{
		
		int arr[][]=new int[a.length()+1][b.length()+1];
		
		for(int i=0;i<a.length();i++)arr[i][0]=0;
		for(int i=0;i<b.length();i++)arr[0][i]=0;
		int max=0;
		for(int i=0;i<a.length();i++)
			for(int j=0;j<b.length();j++)
			{
				if(a.charAt(i)==b.charAt(j))
				{
					arr[i+1][j+1]=arr[i][j]+1;
					if(max<arr[i+1][j+1])max=arr[i+1][j+1];
				}else {
					arr[i+1][j+1]=Math.max(arr[i+1][j],arr[i][j+1]);
				}
			}
		return max;
	}
}
